<template>
	<view class="u-padding-20">
		<u-loading-page :loading="loadstatus"></u-loading-page>
		<view class="" v-if="flow_list.length > 0">
				<view  v-for="(item, key) in flow_list" :key="key">
					<view v-if="item.cover!=null">
						<u--image :src="item.cover" width="100%" height="260px" radius="6"
						@click="$Router.push({path: '/pages/componentsA/durg/archiveinfo', query: {aid: item.aid}})"></u--image>
						<u--text type="info" :text="item.name" size="20" align="center" class="u-m-b-10"></u--text>
					</view>
					<view v-else>
						<view class="boxtype">
							<u--text :text="item.name" size="20" align="center" color="#D8BFD8" lineHeight="40"
							@click="$Router.push({path: '/pages/componentsA/durg/archiveinfo', query: {aid: item.aid}})"></u--text>
						</view>
					</view>
				</view>
			<view v-if="flow_list.length > 0">
			  <u-loadmore :status="loadStatus" @loadmore="getflowlist"></u-loadmore>
			</view>
		</view>
	</view>
</template>


<script>

import {mapState,mapMutations} from 'vuex';
export default {

	data(){
		return {
				flow_list:[],
				page:1,
				loadstatus:false,
				loadStatus:'loadmore',
				tagtypeid:'',
				categoryid:'',
				name:''
			};
	},
	  onReachBottom() {
		if (this.loadStatus=="loadmore"){
			setTimeout(() => {
			  if (this.loadStatus=='loadmore')this.getflowlist();
			}, 50);
		}
	  },
	computed: {
	  ...mapState(['user']),
	},
	 onLoad(options) {
		 let query = JSON.parse(decodeURIComponent(options.query));
		 console.log(query)
		 this.name=query.name
		 this.tagtypeid=query.tagtypeid
		 this.categoryid=query.categoryid
		 this.getflowlist();
	},

methods:{
    getflowlist() {
      return new Promise((resolve, reject) => {
        this.loadstatus = true;
        this.$api("dcd.search", {
          page: this.page,
          name: this.name,
		  tagtypeid:this.tagtypeid,
		  categoryid:this.categoryid
        }).then((res) => {
            console.log(res);
            if (res.code == 200) {
              if (res.data.total > 0) {
                let list = res.data.data;
                if (this.page <= res.data.last_page) {
                  for (let i = 0; i < list.length; i++) {
                    this.flow_list.push(list[i]);
                  }
                  if (this.page == res.data.last_page) {
                    this.loadStatus = "nomore";
                  }
                  this.page += 1;
                } else {
                  this.loadStatus = "nomore";
                }
              } else {
                this.flow_list = [];
                this.loadStatus = "nomore";
              }
            }
			this.loadstatus = false;
          }).catch((e) => {this.loadstatus = false;resolve(false);});
      });
    },
}
	
};
</script>
<style lang="scss" scoped>


</style>
